package ar.com.angrymachine.hunter.locations;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;

import ar.com.angrymachine.hunter.Activity;
import ar.com.angrymachine.hunter.GraphicStyles;
import ar.com.angrymachine.hunter.Locale;
import ar.com.angrymachine.hunter.HunterResourceManager;

public class ColossusClimbableLimbActivity extends Activity
{
	ColossusActivitySet parentActivitySet;
	int climbTime = 0;
	int targetClimbingTime;
	String description;
	
	public ColossusClimbableLimbActivity(ColossusActivitySet parentSet, int climbingTime, String description)
	{
		parentActivitySet = parentSet;
		targetClimbingTime = climbingTime;
		this.description = description;
	}

	public String getDescription()
	{
		return description;
	}
	
	public String getActionText()
	{
		return Locale.CLIMB;
	}

	public void paint(Graphics g, Rectangle activityArea)
	{
        GraphicStyles.paintDefaultActivity(g, this, activityArea, HunterResourceManager.getImage("town-arena.png"));
        if(!isCompleted())
        {
        	Rectangle bar = GraphicStyles.getBarArea(activityArea);
            g.setColor(Color.YELLOW);
            GraphicStyles.paintLabeledBar(g, Locale.HEIGHT, bar, climbTime, targetClimbingTime);
        }
	}

	public void update(int delta, boolean action, boolean timeIsRunning)
	{
		if(timeIsRunning)
		{
			if(action)
			{
				climbTime += delta;
				if(climbTime >= targetClimbingTime)
				{
					climbTime = targetClimbingTime;
					// climbed!
					parentActivitySet.onLimbClimbedComplete(this);
				}
			}
			else
			{
				// if you stop climbing, you fall
				climbTime = 0;
			}
		}
	}
}
